package com.baozun.houji.me.viewmodel

import androidx.lifecycle.MutableLiveData
import com.baozhun.mall.common.model.enums.VerifyCodeType
import com.baozhun.mall.common.model.bean.ResetPwdReqBean
import com.baozun.houji.me.network.mMeApiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request

/**
 * @Title：
 * @Description：
 * @Author：xing.luo
 * @Since：2022/12/9
 * @Version：1.0.0
 */
class ResetPwdViewModel : BaseViewModel() {
    var pwd = MutableLiveData("")
    var email = MutableLiveData("")
    var confirmPwd = MutableLiveData("")


    /**
     * 重置密码
     */
    fun resetPwd(email: String, code: String, ticket: String, registerSuccess: () -> Unit) {
        request(
            {
                mMeApiService.resetPwd(
                    ResetPwdReqBean(
                        email,
                        code,
                        VerifyCodeType.RESET_PWD.type,
                        ticket,
                        pwd.value.toString(),
                        confirmPwd.value.toString()
                    )
                )
            },
            {
                registerSuccess.invoke()
            },
            isShowDialog = true,
            showSuccessMsg = true,
        )
    }

}